
import 'dart:convert';

import 'package:ichinesereader/models/book/BookLevel.dart';
import 'package:ichinesereader/models/common/MyAchievement.dart';
import 'package:ichinesereader/models/common/Settings.dart';
import 'package:ichinesereader/models/student/AssessmentProgress.dart';

ProfileIndividual profileIndividualFromJson(String str) => ProfileIndividual.fromJson(json.decode(str));

String profileIndividualToJson(ProfileIndividual data) => json.encode(data.toJson());

class ProfileIndividual {
    ProfileIndividual({
        this.userId,
        this.userName,
        this.email,
        this.firstName,
        this.lastName,
        this.role,
        this.disabled,
        this.timestampDisabled,
        this.timestampEnabled,
        this.timestampCreated,
        this.timestampPasswordChanged,
        this.profileImageUrl,
        this.settings,
        this.deleted,
        this.lastLoggedIn,
        this.lastLogIn,
        this.accessCode,
        this.worldRank,
        this.race,
        this.programType,
        this.gender,
        this.nickName,
        this.birthDay,
        this.dateOfBirth,
        this.parentEmail,
        this.points,
        this.playerLevel,
        this.pointsCollected,
        this.pointsSpent,
        this.language,
        this.myAchievements,
        this.levelProgress,
        this.assessmentProgress,
        this.gameLevel,
        this.levelPercentage,
        this.excludeFromLeaderboard,
        this.gameDisable,
        this.numBooks,
        this.numQuizzes,
        this.totalLoginTime,
        this.totalGameTime,
        this.bookRead30Days,
        this.bookRead7Days,
        this.quizTaken30Days,
        this.quizTaken7Days,
        this.createDateInDateFormat,
        this.linkTime,
        this.assessmentShortName,
        this.level,
        this.background,
        this.trial,
        this.timestampAccountExpiration,
        this.mode,
        this.braintreeCustomerId,
        this.customerId,
        this.subscriptionId,
        this.phoneNumber,
        this.verified,
        this.theme,
        this.lang,
    });

    String? userId;
    String? userName;
    String? email;
    String? firstName;
    String? lastName;
    List<String>? role;
    bool? disabled;
    dynamic timestampDisabled;
    dynamic timestampEnabled;
    int? timestampCreated;
    int? timestampPasswordChanged;
    dynamic profileImageUrl;
    Settings? settings;
    bool? deleted;
    int? lastLoggedIn;
    dynamic lastLogIn;
    String? accessCode;
    int? worldRank;
    dynamic race;
    dynamic programType;
    String? gender;
    String? nickName;
    dynamic birthDay;
    dynamic dateOfBirth;
    dynamic parentEmail;
    int? points;
    Level? playerLevel;
    int? pointsCollected;
    int? pointsSpent;
    String? language;
    List<MyAchievement>? myAchievements;
    dynamic levelProgress;
    AssessmentProgress? assessmentProgress;
    int? gameLevel;
    int? levelPercentage;
    bool? excludeFromLeaderboard;
    bool? gameDisable;
    int? numBooks;
    int? numQuizzes;
    int? totalLoginTime;
    int? totalGameTime;
    int? bookRead30Days;
    int? bookRead7Days;
    int? quizTaken30Days;
    int? quizTaken7Days;
    dynamic createDateInDateFormat;
    int? linkTime;
    dynamic assessmentShortName;
    String? level;
    dynamic background;
    bool? trial;
    int? timestampAccountExpiration;
    dynamic mode;
    dynamic braintreeCustomerId;
    dynamic customerId;
    dynamic subscriptionId;
    dynamic phoneNumber;
    bool? verified;
    int? theme;
    int? lang;

    factory ProfileIndividual.fromJson(Map<String, dynamic> json) => ProfileIndividual(
        userId: json["userId"],
        userName: json["userName"],
        email: json["email"],
        firstName: json["firstName"],
        lastName: json["lastName"],
        role: json["role"]!=null ? List<String>.from(json["role"].map((x) => x)): null,
        disabled: json["disabled"],
        timestampDisabled: json["timestampDisabled"],
        timestampEnabled: json["timestampEnabled"],
        timestampCreated: json["timestampCreated"],
        timestampPasswordChanged: json["timestampPasswordChanged"],
        profileImageUrl: json["profileImageUrl"],
        settings: json["settings"]!=null ? Settings.fromJson(json["settings"]) : null,
        deleted: json["deleted"],
        lastLoggedIn: json["lastLoggedIn"],
        lastLogIn: json["lastLogIn"],
        accessCode: json["accessCode"],
        worldRank: json["worldRank"],
        race: json["race"],
        programType: json["programType"],
        gender: json["gender"],
        nickName: json["nickName"],
        birthDay: json["birthDay"],
        dateOfBirth: json["dateOfBirth"],
        parentEmail: json["parentEmail"],
        points: json["points"],
        playerLevel:json["playerLevel"]!=null ?  Level.fromJson(json["playerLevel"]): null,
        pointsCollected: json["pointsCollected"],
        pointsSpent: json["pointsSpent"],
        language: json["language"],
        myAchievements: List<MyAchievement>.from(json["myAchievements"].map((x) => MyAchievement.fromJson(x))),
        levelProgress: json["levelProgress"],
        assessmentProgress: AssessmentProgress.fromJson(json["assessmentProgress"]),
        gameLevel: json["gameLevel"],
        levelPercentage: json["levelPercentage"],
        excludeFromLeaderboard: json["excludeFromLeaderboard"],
        gameDisable: json["gameDisable"],
        numBooks: json["numBooks"],
        numQuizzes: json["numQuizzes"],
        totalLoginTime: json["totalLoginTime"],
        totalGameTime: json["totalGameTime"],
        bookRead30Days: json["bookRead30Days"],
        bookRead7Days: json["bookRead7Days"],
        quizTaken30Days: json["quizTaken30Days"],
        quizTaken7Days: json["quizTaken7Days"],
        createDateInDateFormat: json["createDateInDateFormat"],
        linkTime: json["linkTime"],
        assessmentShortName: json["assessmentShortName"],
        level: json["level"],
        background: json["background"],
        trial: json["trial"],
        timestampAccountExpiration: json["timestampAccountExpiration"],
        mode: json["mode"],
        braintreeCustomerId: json["braintreeCustomerId"],
        customerId: json["customerId"],
        subscriptionId: json["subscriptionId"],
        phoneNumber: json["phoneNumber"],
        verified: json["verified"],
        theme: json["theme"] ?? 0,
        lang: json["lang"] ?? 0,
    );

    Map<String, dynamic> toJson() => {
        "userId": userId,
        "userName": userName,
        "email": email,
        "firstName": firstName,
        "lastName": lastName,
        "role": role!=null ? List<dynamic>.from(role!.map((x) => x)) : null,
        "disabled": disabled,
        "timestampDisabled": timestampDisabled,
        "timestampEnabled": timestampEnabled,
        "timestampCreated": timestampCreated,
        "timestampPasswordChanged": timestampPasswordChanged,
        "profileImageUrl": profileImageUrl,
        "settings":settings!=null ? settings?.toJson() : null,
        "deleted": deleted,
        "lastLoggedIn": lastLoggedIn,
        "lastLogIn": lastLogIn,
        "accessCode": accessCode,
        "worldRank": worldRank,
        "race": race,
        "programType": programType,
        "gender": gender,
        "nickName": nickName,
        "birthDay": birthDay,
        "dateOfBirth": dateOfBirth,
        "parentEmail": parentEmail,
        "points": points,
        "playerLevel": playerLevel!=null ? playerLevel?.toJson(): null,
        "pointsCollected": pointsCollected,
        "pointsSpent": pointsSpent,
        "language": language,
        "myAchievements": myAchievements!=null ? List<dynamic>.from(myAchievements!.map((x) => x.toJson())): null,
        "levelProgress": levelProgress?.toJson(),
        "assessmentProgress": assessmentProgress?.toJson(),
        "gameLevel": gameLevel,
        "levelPercentage": levelPercentage,
        "excludeFromLeaderboard": excludeFromLeaderboard,
        "gameDisable": gameDisable,
        "numBooks": numBooks,
        "numQuizzes": numQuizzes,
        "totalLoginTime": totalLoginTime,
        "totalGameTime": totalGameTime,
        "bookRead30Days": bookRead30Days,
        "bookRead7Days": bookRead7Days,
        "quizTaken30Days": quizTaken30Days,
        "quizTaken7Days": quizTaken7Days,
        "createDateInDateFormat": createDateInDateFormat,
        "linkTime": linkTime,
        "assessmentShortName": assessmentShortName,
        "level": level,
        "background": background,
        "trial": trial,
        "timestampAccountExpiration": timestampAccountExpiration,
        "mode": mode,
        "braintreeCustomerId": braintreeCustomerId,
        "customerId": customerId,
        "subscriptionId": subscriptionId,
        "phoneNumber": phoneNumber,
        "verified": verified,
        "theme": theme,
        "lang": lang,
    };
}